#ifndef _SPEEXCODEC_H
#define _SPEEXCODEC_H

#include "base.h"

#include <stdio.h>
#include <string.h>
#include <speex/speex.h>
#include <speex/speex_preprocess.h>    
#include <speex/speex_echo.h>     
#include <speex/speex_jitter.h>

#define SPEEX_LEAVER 8

class CSpeexCodec
{
public:
	CSpeexCodec();
	virtual ~CSpeexCodec();
public:
	void speex_init();
	void speex_destroy();
	void speex_Encode(int nCh, unsigned char *speech, int ninlen, char *bitstream, int& noutlen);
	void speex_Decode(char *bitstream, int ninlen, unsigned char *speech, int& noutlen);
	int GetFrameSamples(int nCh){return gFramesize[nCh];};
private:
	SpeexBits enc_bits[MAX_CHANNEL], dec_bits;
	void* enc_state[MAX_CHANNEL], *dec_state;
	SpeexPreprocessState* m_st[MAX_CHANNEL];
	bool gbinit;
	int gFramesize[MAX_CHANNEL];
};

#endif

